package com.ray.exercise.utils;

import org.apache.shiro.codec.Base64;
import org.apache.shiro.codec.CodecSupport;
import org.apache.shiro.codec.Hex;

/**
 * @author reny
 * created at 2024/6/10 17:29
 **/
public class EncodeUtils {

    public static String base64Encode(String toEncode) {
        return Base64.encodeToString(toEncode.getBytes());
    }

    public static String base64Decode(String toDecode) {
        return Base64.decodeToString(toDecode.getBytes());
    }

    public static String hexEncode(String toEncode) {
        return Hex.encodeToString(toEncode.getBytes());
    }

    public static String hexDecode(String toDecode) {
        byte[] decode = Hex.decode(toDecode);
        return CodecSupport.toString(decode);
    }
}
